<template>
  <div class="cart-single">
    <input type="checkbox" />
    <img :src="cartGood.s_good.s_goods_photos[0].path" alt="" />
    <p>{{ cartGood.s_good.name }}</p>
    <p><span>价格</span>{{ cartGood.s_good.price }}</p>
    <p><span>数量</span><input type="number" v-model="num" /></p>
    <p><span>小计</span>{{ total }}</p>
    <button @click="delGood">删除</button>
  </div>
</template>

<script>
import { delCart } from "../assets/request.js";
export default {
  name: "CartSingle",
  data() {
    return {
      cartGood: {},
      num: 0,
    };
  },
  props: ["goodId"],
  methods: {
    async delGood() {
      const resDelGood = await delCart(this.cartGood.id);
    },
  },
  computed: {
    total() {
      return this.num * this.cartGood.s_good.price;
    },
  },
  async mounted() {
    const resGood = await getGood;
    this.num = this.cartGood.num;
  },
};
</script>

<style lang="scss" scoped>
.cart-single {
  display: flex;
}
</style>
